// 验证规则
$('#applyDel').validate({
    rules: {
        payWhat: {
            required: true
        },
        safepass: {
            required: true,
            password: true
        }
    },
    errorPlacement: function (error, element) {
        $(element).siblings('.u-ts').html(error)
    },
    errorElement: 'span',
    submitHandler: function (form) {
        $(form).ajaxSubmit({
            type: "POST",
            dataType: "json",
            beforeSend: function () {
                $(".apply_sq").addClass('grey').attr('disabled', 'disabled');
            },
            success: function (data) {
                $(".apply_sq").removeClass('grey').removeAttr('disabled');
                if (data.code == 0) {
                    toastr.success(data.msg);
                    setInterval(function () {
                        window.location.reload();
                    }, 1500);
                }
                if (data.code == 1) {
                    toastr.error(data.msg);
                }
            }
        });
    }
});

jQuery.validator.addMethod('password', function (value, element) {
    var password = /^[A-Za-z0-9_-]{6,18}$/.test(value);
    return this.optional(element) || password
}, '请输入6-18位字母，数字_-');


